package com.example.widgettest_206shj;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class NewActivity extends AppCompatActivity implements View.OnClickListener{

    //千万不要在这直接findViewByID，会出大事的！！
    private TextView t1, t2;
    private Button b1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);
        initView();
        Intent intent = getIntent();
        String str = intent.getStringExtra("param1");
        int n = intent.getIntExtra("param2",10);
        Toast.makeText(this, str + "---" + String.valueOf(n), Toast.LENGTH_SHORT).show();
        //获取控件，设置TestView文本
        t1.setText("String : " + str + "   ");
        t2.setText("Int : " + n);
    }

    public void initView(){
        b1 = (Button) findViewById(R.id.button3);
        t1 = (TextView) findViewById(R.id.tv1);
        t2 = (TextView) findViewById(R.id.tv2);

        b1.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button3:
                finish();
                break;
        }
    }
}
